#include "dominion.h"
#include "dominion_helpers.h"
#include "testutils.h"
#include <stdio.h>
#include <stdlib.h>

// This unit test was added after suspicious behavior of the remodel card was
// detected with random testing.

// After fixing the first bug, buggy behavior was *still* detected with random
// testing, so the unit test was expanded to include trashing a copper and 
// gaining a copper.

void testRemodelEffect (    int args[MAX_PLAYARGS], int cardtypes[MAX_PLAYARGS],
                            carddesc_t desc, struct gameState *g,
                            expectedState_t *expected )
{
    expected->count[cardtypes[1]]--;
    expected->count[cardtypes[2]]++;
    
    bool expect_fail = getCost (cardtypes[1]) + 2 < getCost (cardtypes[2]);
    
    pass_printf (   "%s: TEST trashing %s in favor of %s using %s\n", 
                    __func__, desc[1], desc[2], desc[0] );
    
    testPlayCard (args[0], args[1], args[2], args[3], g, expected, expect_fail);
    
    testEndTurn (g, expected);
}

int main (int argc, char *argv[])
{
    parse_args (argc, argv);
    
    static playargs_t playargs =
    {
        {arg_handcard,  remodel, remodel},
        {arg_handcard,  0, treasure_map},
        {arg_cardtype,  0, treasure_map},
    };
    
    run_cardtest (playargs, testRemodelEffect);
    
    return EXIT_SUCCESS;
}
